<template>
  <div>
    <div class="demo-inner-divider">提示框</div>
    <div class="container">
      <div class="top">
        <e-tooltip
          width="600"
          content="Top Left text"
          placement="top-start"
        >
          <div>
            <e-button>Top Left</e-button>
          </div>
        </e-tooltip>
        <e-tooltip content="Top Center text" placement="top">
          <e-button>Top Center </e-button>
        </e-tooltip>
        <e-tooltip content="Top Right text" placement="top-end">
          <e-button>Top Right</e-button>
        </e-tooltip>
      </div>
      <div class="center">
        <div class="center-left">
          <e-tooltip content="Left Top text" placement="left-start">
            <div>
              <e-button>Left Top</e-button>
            </div>
          </e-tooltip>
          <br />
          <br />
          <e-tooltip content="Left Center text" placement="left">
            <div>
              <e-button>Left Center</e-button>
            </div>
          </e-tooltip>
          <br />
          <br />
          <e-tooltip content="Left Bottom text" placement="left-end">
            <div>
              <e-button>Left Bottom</e-button>
            </div>
          </e-tooltip>
        </div>
        <div class="center-right">
          <e-tooltip content="Right Top text" placement="right-start">
            <div>
              <e-button>Right Top</e-button>
            </div>
          </e-tooltip>
          <br />
          <br />
          <e-tooltip content="Right Center text" placement="right">
            <div>
              <e-button>Right Center</e-button>
            </div>
          </e-tooltip>
          <br /><br />
          <e-tooltip content="Right Bottom text" placement="right-end">
            <div>
              <e-button>Right Bottom</e-button>
            </div>
          </e-tooltip>
        </div>
      </div>
      <div class="bottom">
        <e-tooltip content="Bottom Left text" placement="bottom-start">
          <e-button>Bottom Left</e-button>
        </e-tooltip>
        <e-tooltip content="Bottom Center text" placement="bottom">
          <e-button>Bottom Center</e-button>
        </e-tooltip>
        <e-tooltip content="Bottom Right text" placement="bottom-end">
          <e-button>Bottom Right</e-button>
        </e-tooltip>
      </div>
    </div>

    <div class="demo-inner-divider">带操作文字提示</div>
    <div class="demo-content">
      <e-tooltip placement="left" :max-width="250">
        <div>带操作，试试</div>
        <template #content>
          <span>真的有！镜像是一个包含了操作系统及必要配置的云主机模板，查看</span>
          <a>
            <span>配置案例</span>
            <e-icon type="skip" size="14" />
          </a>
        </template>
      </e-tooltip>
    </div>

    <div class="demo-inner-divider">带标题的文字提示</div>
    <div class="demo-content demo-title-container">
      <e-tooltip placement="right" :max-width="250">
        <div>有标题！</div>
        <template #content>
          <div class="tooltip-title">标题</div>
          <div class="tooltip-content">
            <div class="item">镜像是一个包含了操作系统及必要配置的云主机模板，使用镜像可以创建云主机。</div>
            <div class="item">镜像是一个包含了操作系统及必要配置的云主机模板，使用镜像可以创建云主机。</div>
            <div class="item">镜像是一个包含了操作系统及必要配置的云主机模板，使用镜像可以创建云主机。</div>
            <div class="item">其实是自己写的slot，看看API</div>
          </div>
        </template>
      </e-tooltip>
    </div>

    <div class="demo-inner-divider">基础文字提示-不带箭头的文字提示</div>
    <div class="demo-content">
      <e-tooltip
        placement="top-start"
        content="不带箭头的文字提示"
        :visible-arrow="false"
      >
        <e-button>No arrow</e-button>
      </e-tooltip>
    </div>

    <div class="demo-inner-divider">自定义内容</div>
    <div class="demo-content">
      <e-tooltip placement="top-start">
        <e-button>Multiple lines</e-button>
        <template #content>
          <p>Display multiple lines of information</p>
          <p><i>Can customize the style</i></p>
        </template>
      </e-tooltip>
    </div>

    <div class="demo-inner-divider">禁用</div>
    <div class="demo-disable">
      <e-tooltip
        placement="top"
        content="Can disable text prompts"
        :disabled="disabled"
      >
        <e-button @click="disabled = true">Click to close</e-button>
      </e-tooltip>
    </div>

    <div class="demo-inner-divider">延时</div>
    <div class="demo-delay">
      <e-tooltip placement="top" content="Tooltip text" :delay="1000">
        <e-button @click="disabled = true">Delay 1 second to show</e-button>
      </e-tooltip>
      <e-tooltip placement="top" content="Tooltip text" :disappear="1000">
        <e-button @click="disabled = true">Delay 1 second to disappear</e-button>
      </e-tooltip>
    </div>

    <div class="demo-inner-divider">主题</div>
    <div>
      <e-tooltip content="content of tooltip">
        <e-button type="primary">Dark(default)</e-button>
      </e-tooltip>
      <e-tooltip content="content of tooltip" theme="light">
        <e-button>Light</e-button>
      </e-tooltip>
    </div>
    <div class="demo-inner-divider">自动换行</div>
    <div class="demo-auto">
      <e-tooltip max-width="200" placement="top-start">
        <e-button type="primary">Long Content</e-button>
        <template #content>
          <div>
            Steven Paul Jobs was an American entrepreneur and business magnate.
            He was the chairman, chief executive officer, and a co-founder of
            Apple Inc.
          </div>
        </template>
      </e-tooltip>
    </div>

    <div class="demo-inner-divider">提示框-slot</div>
    <div class="demo-item">
      <e-tooltip always content="使用slot" placement="top">
        <div><e-icon type="add-rectangle" :size="15"></e-icon></div>
      </e-tooltip>
    </div>

    <div class="demo-inner-divider">提示框-内容带icon</div>
    <div>
      <e-tooltip placement="top-start">
        <template #content>
          <e-icon type="warning" :size="15" :color="'red'"></e-icon>
          <span>这里是提示</span>
        </template>
        <div class="my-area"></div>
      </e-tooltip>
    </div>
    <tooltip-md class="markdown-body"></tooltip-md>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import tooltipMd from '../../docs/tooltip.md'
let disabled = ref(false)
</script>

<style lang="less" scoped>
.container {
  .haloe-tooltip {
    margin: 0 3px;
  }
  .center {
    width: 500px;
    margin: 10px auto;
    overflow: hidden;
  }
  .top,
  .bottom {
    text-align: center;
  }
  .center-left {
    float: left;
  }
  .center-right {
    float: right;
  }
}

// 带标题的文字提示
.demo-title-container {
  ::v-deep .haloe-tooltip-popper {
    .haloe-tooltip-content {
      .haloe-tooltip-inner {
        padding: 0;
        .tooltip-title {
          height: 34px;
          background: #434F67;
          font-size: 14px;
          font-weight: 500;
          padding: 8px;
          border-bottom: 1px solid #5C6A87;
        }
        .tooltip-content {
          .item {
            padding: 8px;
            &:not(:last-child) {
              border-bottom: 1px dashed#5C6A87;
            }
          }
        }
      }
    }
  }
}


.my-area {
  width: 70px;
  height: 70px;
  background-color: plum;
}
</style>
